<?php
	include("common/connection.php");
	echo $search=$_GET['search'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>::.IBA REUNION 2012.::</title>
<link rel="stylesheet" href="style/style.css" type="text/css" /> 

<script language="javascript" type="text/javascript">

function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	function getBatch(groupId) {		
		
		var strURL="findbatch.php?group="+groupId;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('statediv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
	
	function AjaxFunction(email)
	{
		//alert(email);
		var url="validation.php";
		url=url+"?email="+email;
		url=url+"&sid="+Math.random();
		var reqEmqil = getXMLHTTP();
		
		if (reqEmqil) {
			
			reqEmqil.onreadystatechange = function() {
				if (reqEmqil.readyState == 4) {
					// only if "OK"
										
						document.getElementById("msg").innerHTML=reqEmqil.responseText;						
					
				}				
			}			
			reqEmqil.open("GET", url, true);
			reqEmqil.send(null);
		}
	 
	}
	
</script>
</head>

<body topmargin="0" leftmargin="0">

    <form name="regis" action="life-members.php?search=result" method="post">
   <table cellspacing="20" cellpadding="10" align="center">
                        <tr>
                            <td> Group </td>
                            <td> <select name="group" id="group" onChange="getBatch(this.value)" class="validate[required]">
                                  <option value="">&nbsp;&nbsp;- - -</option>
								  <option value="1">BBA</option>
								  <option value="2">MBA</option>
								  <option value="3">EMBA</option>
								  <option value="4">Fellow</option>
								  <option value="5">Honorary</option>
								  <option value="6">Associate</option>
								</select>
                            </td>                                
                            <td valign="top"> Batch </td>
                            <td valign="top"> <div id="statediv" style="position:absolute"><select name="batch" id="batch" >
										<option>---</option>
											</select></div>                                  
                            </td>
							<td></td>
							<td>Name</td>
							<td><input type="text" name="name" /></td>
							<td><input type="submit" value="submit" /></td>
							
						</tr>
	</table>
	</form>
	<table width="630" border="1" align="center">
		<tr>
			<td>SI No</td>
			<td>GROUP</td>			
			<td>Batch</td>
			<td>Name</td>
		</tr>
	<?php
		//SELECT * FROM  `tmembers` WHERE  `batch` LIKE  '%'
		if($search=='result'){
			$group=$_POST['group'];
			if($group=='')$group='%';
			if($group=='1')$group='BBA';
			if($group=='2')$group='MBA';
			if($group=='3')$group='EMBA';
			if($group=='4')$group='Fellow';
			if($group=='5')$group='Honorary';
			if($group=='6')$group='Associate';
			$batch=$_POST['batch'];
			if($batch==''||$batch=='---')$batch='%';
			$name=$_POST['name'];
			if($name!='')$name='%'.$name.'%';
			if($name=='')$name='%';
			$i=1;
			echo $sql="SELECT * FROM tmembers WHERE `batch` LIKE  '$batch' AND `mgroup` LIKE  '$group' AND `name` LIKE  '$name' order by mgroup, batch";
			$result=mysql_query($sql);
			echo $norows=mysql_num_rows($result);
			while($row=mysql_fetch_assoc($result)){
	?>
		<tr>
			<td><?php echo $i;?></td>
			<td><?php echo $row['mgroup'];?></td>		
			<td><?php echo $row['batch'];?></td>
			<td><?php echo $row['name'];?></td>	
		</tr>
	
	<?php $i++;} }?>
	</table>
</body>
</html>
